import http from '@/Services/Request'

const base = '/api/Orders'

export default {
    /** 获取所有订单 */
    GetAll() {
        return http.get(base)
    },

    /** 根据ID获取订单 */
    GetById(id) {
        return http.get(`${base}/${id}`)
    },

    /** 创建订单 */
    Create(model) {
        return http.post(base, model)
    },

    /** 更新订单 */
    Update(id, model) {
        return http.put(`${base}/${id}`, model)
    },

    /** 删除订单 */
    Delete(id) {
        return http.delete(`${base}/${id}`)
    },

    /** 获取用户的订单 */
    GetUserOrders(userId) {
        return http.get(`${base}/user/${userId}`)
    },

    /** 更新订单状态 */
    UpdateStatus(id, status) {
        return http.put(`${base}/${id}/status?status=${encodeURIComponent(status)}`)
    },

    /** 根据商品ID获取订单 */
    GetByProductId(productId) {
        return http.get(`${base}/product/${productId}`)
    }
} 